package com.entor.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.entor.model.EduTeacher;
import com.entor.service.EduTeacherService;
import com.entor.util.ChartUtil;
import com.entor.util.Msg;
import com.entor.util.StringUtil;

@Controller
@RequestMapping("/teacher")
public class EduTeacherController 
extends BaseController{
	
	@Resource(name="eduTeacherService")
	private EduTeacherService ets;
	
	@RequestMapping("/index")
	public String index(){
		return "/teacher/teacherIndex";
	}
	
	@RequestMapping("/aoe")
	public String addOrEdit(){
		return "/teacher/addOrEdit";
	}
	
	@RequestMapping("/find")
	@ResponseBody
	public List<EduTeacher> find(EduTeacher t){
		List<EduTeacher> list = ets.find(t);
		return list;
	}
	@RequestMapping("/add")
	@ResponseBody
	public Msg add(EduTeacher t){
		return ets.add(t);
	}
	
	@RequestMapping("/getLoginName")
	@ResponseBody
	public Msg getLoginName(HttpServletRequest req){
		String name = req.getParameter("name");
		String brith = req.getParameter("birth");
		
		Msg m = new Msg();
		String frist = StringUtil.getFristCh(name);
		brith = brith.replace("-", "");
		m.setMsg(frist+brith);
		m.setSus(true);
		return m;
	}

}
